<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2019-01-14
  Time: 18:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>采购单据查询</title>
    <jsp:include page="${pageContext.request.contextPath}/common/tag.jsp"/>


</head>
<script>
    $(function () {
        $('#datetimepicker2').datetimepicker({
            format:'YYYY-MM-DD',
            locale:moment.locale("zh-cn")
        });
        $('#datetimepicker1').datetimepicker({
            format: 'YYYY-MM-DD',
            locale: moment.locale('zh-cn')
        });
        $("#mytable").bootstrapTable({
            url:'${pageContext.request.contextPath}/audit/query',
            type:'post',
            height:400,
            pagination:true,
            pageSize:5,
            pageList:[2,4,8,16],
            pageNumber:1,
            sidePagination:'server',  //启用服务器端分页
            queryParams:function (params) {
                var temp={
                    danhao:$("#danhao").val(),
                    adstid:$("#adst").val(),
                    date1:$("input[name='date1']").val(),
                    date2:$("input[name='date2']").val(),
                    limit: params.limit,  //页面大小
                    offset: params.offset //页码
                };
                return temp;
            },
            columns:[
                {field:'danhao',title:'单据号',align:'center'},
                {field:'astatic.asname',title:'审核状态',align:'center'},
                {field:'fkfenlei.rkname',title:'入库分类',align:'center'},
                {field:'cgdate',title:'入库时间',align:'center'},
                {field:'yingshou',title:'应收金额',align:'center'},
                {field:'shishou',title:'实收金额',align:'center'},
                {field:'shuliang',title:'数量',align:'center'},
                {field:'staff.yName',title:'经办人',align:'center'},
                {field:'beizhu',title:'备注',align:'center'}
            ]
        });
    });
    $.post("${pageContext.request.contextPath}/rkfenlei/queryAll",function (data) {
        $.each(data, function (index, item) {
            $("#adst").append("<option value=\"" + item.asid + "\">" + item.asname + "</option>");
        });
    });
    function sou(){
        //返回表格的options
        var options = $("#mytable").bootstrapTable("getOptions");
        var danhao = $("#danhao").val();
        var adstid = $("#adst").val();
        var date1= $("input[name='date1']").val();
        var date2= $("input[name='date2']").val();
        var limit = options.pageSize;
        var offset = (options.pageNumber-1)*limit;
        $.post("${pageContext.request.contextPath}/audit/query",{'danhao':danhao,'adstid':adstid,'date1':date1,'date2':date2,'offset':offset,'limit':limit},function (data) {
            // var mydata = eval("("+data+")") ;
            //重新绑定表格数据
            $("#mytable").bootstrapTable('load',data) ;
        })
    }
</script>
<body style="margin: 20px 20px;overflow-y: hidden">
<div>
    <form class="form-inline" style="margin-top: 20px">
        <div class="form-group">
            <label class="control-label">请选择审核状态:</label>
                <select name="adstid" id="adst" class="form-control" style="width:100px ;">
                        <option value="0">全部</option>
                </select>

            &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;
            <label class="control-label">请输入单据号:</label>
            <input type="text" name="danhao" id="danhao" style="height:30px ;" class="control-label" placeholder="请输入单据号" >
            &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;

            <label class="control-label">选择时间:</label>

                <div class="input-group" id="datetimepicker1">
                    <input name="date1" type='text' class="control-label"  style="height:30px ;" />
                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                </div>
                -
                <div class="input-group" id="datetimepicker2">
                    <input name="date2" type='text' class="control-label" style="height:30px ;"/>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                </div>
            <button type="button" onclick="sou()" class="btn btn-primary" style="margin-left: 45px"><span class="glyphicon glyphicon-search"></span>搜索</button>
            </div>

    </form>
<table id="mytable"></table>
</div>
</body>
</html>
